package com.example.lanqiaodemo1.JavaTest7;

import java.io.*;

public class OutIn1 {

	public static void Out() throws Exception {
		File f = null;
		try {
			f = new File("d:\\out1.bin");
		} catch (Exception exception) {
			exception.printStackTrace();
		}
		assert f != null;
		DataOutputStream dos = new DataOutputStream(new FileOutputStream(f));
		for (int i = 1; i < 101; i++) {
			dos.writeInt(i);
		}
		dos.close();
	}


	public static void In() throws Exception {
		File f = new File("d:\\out1.bin");
		DataInputStream dis=new DataInputStream(new FileInputStream(f));
		try {
			while (true) {
				System.out.println(dis.readInt()+" ");
			}
		} catch (Exception e) {
			System.out.println("文档已到结尾！");
		}
		dis.close();
	}


	public static void main(String[] args) {

			try {
				OutIn1.Out();
			} catch (Exception e) {
				e.printStackTrace();
			}
			try {
				OutIn1.In();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

}



